﻿using System.AddIn.Pipeline;
using RootfusAddinView;
using RootfusAddinContracts;
using System;

namespace RootfusAddinAddinSideAdapters
{
    [AddInAdapter]
    public class PinDefinitionViewToContractAdaptor : ContractBase, IPinDefinitionContract
    {
        PinDefinition _pin;

        public PinDefinitionViewToContractAdaptor(PinDefinition pin)
        {
            _pin = pin;
        }

        public PinDefinition GetSourceView()
        {
            return _pin;
        }

        #region IPinDefinitionContract Members

        public string Name
        {
            get { return _pin.Name; }
        }

        public RootfusAddinContracts.PinConnectionType ConnectionType
        {
            get {
                switch (_pin.ConnectionType)
                {
                    case RootfusAddinView.PinConnectionType.PinInfinite:
                        return RootfusAddinContracts.PinConnectionType.PinInfinite;
                    case RootfusAddinView.PinConnectionType.PinSingle:
                        return RootfusAddinContracts.PinConnectionType.PinSingle;
                    default:
                        throw new Exception("Not implemented!");
                }
            }
        }

        #endregion
    }
}
